<?php

require_once 'OAuth/Signature/Abstract.php';

class OAuth_Signature_Rsa extends OAuth_Signature_Abstract
{

    public function sign(array $params, $method = null, $url = null)
    {
        $result = openssl_get_privatekey($this->_key);
        if (!$result) {
            require_once 'OAuth/Exception.php';
            throw new OAuth_Exception('Unable to load private key');
        }
        $signature = '';
        $result = openssl_sign(
            $this->_getBaseSignatureString($params, $method, $url),
            $signature,
            $result,
            $this->_hashAlgorithm
        );
        return base64_encode($signature);
    }

    protected function _assembleKey()
    {
        return $this->_consumerSecret;
    }

}